<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <p>这是一个p标签</p>
    </div>
    <script>
        var div = document.querySelector("div")
        var p = document.querySelector("p")
        //替换
        //创建一个h2
        var h2 = document.createElement("h2")
        h2.innerHTML = "标题2"
        //爹.replaceChild(新儿子,旧儿子)//用新儿子来替换掉旧儿子
        div.replaceChild(h2,p)



    </script>
</body>
</html>